package com.ngc.mall.controller;

import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.StoreDomain;
import com.ngc.mall.service.IStoreService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * 门店
 * @author: chenxiaolin
 * @date 2023/9/16 15:15
**/
@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private IStoreService iStoreService;

    @GetMapping("/list")
    @ApiOperation("查看所有门店")
    public ResponseResult<List<StoreDomain>> selectAll(){
        return ResponseResult.success(iStoreService.selectAll());
    }

    @PostMapping("")
    @ApiOperation("新增门店")
    public ResponseResult<Long> createStore(@RequestBody StoreDomain storeDomain){
        return ResponseResult.success(iStoreService.createStore(storeDomain));
    }

    @PutMapping("/id/{id}")
    @ApiOperation("根据id更新门店")
    public ResponseResult<Boolean> updateStoreById(@PathVariable Long id,@RequestBody StoreDomain storeDomain){
        return ResponseResult.auto(iStoreService.updateStoreById(id,storeDomain));
    }
}
